#ifndef _CARD_H_
#define _CARD_H_
#include <time.h>
#include <vector>
using namespace std;

const int packSize   =	52;
const int blackJoker =	53;
const int redJoker   =	54;

enum Suit	{ diamonds = 0 ,clubs = 1, hearts = 2, spades = 3 , trump=4};
enum State	{ inpool=0, userhand=1, dropped=2};
enum PlayerState 
			{ alive=0, giveup=1};
enum Hand	{	sigle=0,
				onepair=1, 
				twopair=2, 
				threeofakind=3, 
				fullhouse=4, 
				fourofakind=5,
				straight=6, 
				hflush=7, 
				straightflush=8, 
				royalflush=9};
struct HandInfo 
{
	Hand  h_;
	int   v_;
};

class Card 
{
public:
    Card(int value,State state);
	int  getValue()     const	{ return value_;		}
	int  getSuitValue() const	{ return suitValue_;	}
    Suit getSuit()      const	{ return suit_;			}
	int  getState()		const	{ return state_;		}
	void setState(State state)	{ state_ = state;		}
	void show();
	void print(const char* suitname);

private:
    Suit	suit_;
	int		value_;
    int		suitValue_;
	State	state_;
};

//bool operator < (Card& first, Card& second)
//{
//	return first.getSuitValue()<second.getSuitValue();
//}

class Pack
{
public:

	~Pack();

	void	init();
	void    init(int number);
	void	show();
	void	shuffle();
	bool	deal(int count, vector<Card*>& cardList);
	Card*	dealOne();
	Card*	draw(int index=1);

private:
	vector <Card*> pack_;
};

class Player
{
public:
	Player();
	void init();
	void show();
	void showHand();
	bool ante(int USD);
	void out();
	void moneyAdd(int USD){money_+=USD;}
	int  getMoney(){return money_;}
	void setWin(bool bw){isWin_=true;}
	bool isWin(){return isWin_;}
	vector<Card*>& bid();
	vector<Card*>& getHand(){return hand_;}
private:
	vector<Card*>	hand_;  // now only care the cards in hand 	
	PlayerState		state_;
	int	money_;
	bool isWin_;
};
class Game
{
public:
	Game();
	void start();
	void end();
	void startRound();
	void endRound();
	void init();
	void show();
	void shuffle();
	void usage();
	void computerInfo();
	void playerInfo();
	void deal();
	bool isstart(){return start_;}
	bool isWin();
	void setWin(bool bw);
	bool ante(int USD);
	void stakeAdd(int USD);
	bool isFinish(){ return cardCount_>=5; }
	bool Compare();
	HandInfo GetHandInfo(Player& p );

	int getMaxValue(vector<Card*>& vc);
	int getMinValue(vector<Card*>& vc);
	bool isRoyalFlush(vector<Card*>& vc);
	bool isStraightFlush(vector<Card*>& vc);
	bool isFlush(vector<Card*>& vc);
	bool isStraight(vector<Card*>& vc);
	bool isFourOfAKind(vector<Card*>& vc);
	bool isFullHouse(vector<Card*>& vc);
	bool isThreeOfAKind(vector<Card*>& vc);
	bool isTwoPair(vector<Card*>& vc);
	bool isOnePair(vector<Card*>& vc);


private:
	Pack	pk_;
	Player	play_,computer_;
	bool	start_;
	int		stake_;
	int		cardCount_;
};

#endif // _CARD_H_
